package com.zp.thread;
/**
 * 线程中的两个线程，成员变量
 */
public class ThreadTest4 {
	public static void main(String[] args) {
		Runnable r = new Thread5();
		Thread t1 = new Thread(r);
	    r = new Thread5();
		Thread t2 = new Thread(r);
		t1.start();
		t2.start();
	}
}

class  Thread5 implements Runnable{
	//成员变量
//	int i;
	
	@Override
	public void run() {
		//局部变量：必须初始化；
		int i = 0;
		while(true){
			System.out.println("number"+(i++));
			try {
				//Math.random()：产生0^1之间的随机数；
				Thread.sleep((long)(Math.random()*1000));
			} catch (InterruptedException e) {
				e.printStackTrace();
			}
			//使用break终止循环；
			if(50 == i){
				break;
			}
		}
	}
}